<?php

namespace App\Jobs;
use App\Exceptions\ApiException;
use App\Libraries\GroupPush;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class GroupSendPush implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

     protected $array;
     protected $title;
     protected $content;
     protected $extra;

    /**
     * Create a new job instance.
     *
     * @return void
     */
     public function __construct($array)
     {
          $this->array = $array;
     }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
         $msg = new GroupPush();
         $return = $msg->send($this->array);
         if(empty($return)){
              throw new ApiException('发送推送失败');
         }
    }
    public function failed($exception = null)
    {
         send_mail('382820748@qq.com',$this->array['mobile'].'发送消息队列失败,时间：'.time2date());
    }
}
